package org.xg.study.pd.store.impl;

import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xg.study.pd.card.IQiYiCardService;
import org.xg.study.pd.store.ICommodity;

import java.util.Map;

/**
 * @author CMG
 * @version 1.0
 * @cLassName CardCommodityService
 * @description 第三方兑换卡发放接口
 * @date 2021/9/9 9:56
 **/
public class CardCommodityService implements ICommodity {
    private Logger logger = LoggerFactory.getLogger(CardCommodityService.class);

    //模拟注入
    private IQiYiCardService iQiYiCardService = new IQiYiCardService();

    @Override
    public void sendCommodity(String uId, String commodityId, String bizId, Map<String, String> extMap) throws Exception {
        String mobilePhone = queryUserMobile(uId);
        iQiYiCardService.grantToken(mobilePhone, bizId);
        logger.info("请求参数【爱奇艺兑换卡】=> uId:{}, commodity:{}, bizId:{}, extMap:{}", uId, commodityId, bizId, JSONObject.toJSON(extMap
        ));
        logger.info("测试结果【爱奇艺兑换卡】：success");
    }

    private String queryUserMobile(String uId) {
        return "15200101232";
    }
}
